package com.xing.libao.cron;

import com.xing.libao.util.RequestUtil;
import org.apache.http.Consts;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xingzhe
 * Date: 2015/8/4
 * Time: 14:44
 */
public class CheckOut {
    public static void main(String[] args) {
        RequestUtil requestUtil = RequestUtil.getInstance();
        HttpPost post = new HttpPost("http://gw.e.360buy.com/client.action?functionId=signGetScore");
        post.setHeader("Host","gw.e.360buy.com");
        post.setHeader("User-Agent","JDRead 3.3.1 rv:0729 (iPhone; iPhone OS 8.1; zh_CN)");
        post.setHeader("Connection","close");
        post.setHeader("Accept-Encoding","gzip");
        post.setHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
        post.setHeader("Cookie","_applogin_=KASRHJ2XSLEQ3SIHIRY2GPJRVFCAFTTAKMJBZDU7CRBSNHRQA3GLFVP6PQFJJ5DIRQWAKE6F3ZYMI5NTVV2KYLRE3PWPMZT466DLMJVS3JFLOAVFRTJRX3RHIH7SER6KQAW57UMRCRJFPSY5WWWLRNGI6TLP7KM56RMHLVERMIKXNM5VVNMQ");
        List<NameValuePair> list = new ArrayList<NameValuePair>();
        list.add(new BasicNameValuePair("body", ""));
        list.add(new BasicNameValuePair("brand", "apple"));
        list.add(new BasicNameValuePair("appId", "2"));
        list.add(new BasicNameValuePair("uuid", "83d4d47f8077a8949bb587879831de6e65b29c36"));
        list.add(new BasicNameValuePair("model", "haha iPhone"));
        list.add(new BasicNameValuePair("osVersion", "8.1"));
        list.add(new BasicNameValuePair("client", "iphone"));
        list.add(new BasicNameValuePair("clientVersion", "3.3.1"));
        list.add(new BasicNameValuePair("os", "iphone"));
        list.add(new BasicNameValuePair("screen", "1136*640"));
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, Consts.UTF_8);
        post.setEntity(entity);
        System.out.println(requestUtil.postHtml(post));
    }

    private static void checkin115(){
        String url = "http://mapp.115.com/?ct=checkin";
        String tokenUrl = "http://mapp.115.com/?ctl=checkin&ac=checkin&token=20e07ff8789c4be6d7e741d11f657609";
        RequestUtil requestUtil = RequestUtil.getInstance();
        HttpGet get = new HttpGet(url);
        get.setHeader("Cookie","115_lang=zh; CID=0329346e7de902f299dcf08776a38a0a; OOFA=%2507%250ETSWZ%2507%250CC%2505%2540%250BX%2505LZW%2502%255CU%250D%2506%250B%255D%2505RV%255CT%255B%2502%2502%250F%2503%2503P%2500%2507%2503%2502U%2505%250E%2506%2503%255B%2501%2507%2503%250F_S%250B%2503RV%2501RTPQY%2500%250A%2502; PHPSESSID=fj9a32c4uq4bt52b9c5vora6n2; SEID=cc3e4be2edefa51e301b0b1a117f4a7c20a53698181255f0d7f76731d609026acac4b776b595a513d83c48844819d08dc9bdb6ea33c105bb23b8ea7f; ssov_2955186=1_2955186_181c9134447ce8222432f8f4e9bc0352; UID=2955186_D1_1438877497");
        String content = requestUtil.getHtml(get);
        if(content.contains("今天未签到")){
            HttpGet checkIn = new HttpGet(tokenUrl);
            checkIn.setHeader("Cookie","115_lang=zh; CID=0329346e7de902f299dcf08776a38a0a; OOFA=%2507%250ETSWZ%2507%250CC%2505%2540%250BX%2505LZW%2502%255CU%250D%2506%250B%255D%2505RV%255CT%255B%2502%2502%250F%2503%2503P%2500%2507%2503%2502U%2505%250E%2506%2503%255B%2501%2507%2503%250F_S%250B%2503RV%2501RTPQY%2500%250A%2502; PHPSESSID=fj9a32c4uq4bt52b9c5vora6n2; SEID=cc3e4be2edefa51e301b0b1a117f4a7c20a53698181255f0d7f76731d609026acac4b776b595a513d83c48844819d08dc9bdb6ea33c105bb23b8ea7f; ssov_2955186=1_2955186_181c9134447ce8222432f8f4e9bc0352; UID=2955186_D1_1438877497");
            content = requestUtil.getHtml(checkIn);
            System.out.println(content);
        }else{
            System.out.println(content);
            System.out.println("注册失败");
        }
    }
}
